import {createRouter, createWebHistory,createWebHashHistory } from 'vue-router'
import Index from '../pages/Index.vue'

const routes = [
    {
        path: '/',
        name: 'Index',
        component: Index,
        meta: {
            title: '预约中心'
        }
    },
    // 通配符路由，用于捕获所有未匹配的路由
    {
        path: '/:catchAll(.*)',
        name: 'NotFound',
        component: Index,
    },
]


const router = createRouter({
    history: createWebHashHistory(process.env.BASE_URL),
    routes
})

// 在导航守卫中设置网页标题
router.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title;
    }
    next();
});

export default router
